import QtQuick 1.0
import "CommomUtil.js" as CommonUtil
import com.meego 1.0
import "Forum.js" as ForumUtil

Item {
    id: listItem

    width: 480
    height: 100


Rectangle{
    id:listTiem_rect
    anchors.fill: parent

    //精，荐,图
     Rectangle{
        id:topicType_rect
        width: 50; height:parent.height
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.leftMargin: 5
        color:ForumUtil.getTopicTypeColor(topicTypeName)

       Text{
           id:topicType_name
           text:topicTypeName
           color:"white"
           anchors.top: parent.top
           anchors.topMargin: 10
           anchors.horizontalCenter: parent.horizontalCenter
           font { bold: true; family: "Helvetica"; pointSize: 18 }
        }
    }
     //帖子标题
     Rectangle{
            id:topicList_rect
            width: parent.width - 55; height: parent.height
            anchors.left: topicType_rect.right; anchors.leftMargin:5
            anchors.top: parent.top
            color:"#ebeff9"

        Column {
               id: column


               Text {
                    id: topicTitle_text
                    width: topicList_rect.width; height: 60
                    anchors.left: topicList_rect.left; anchors.top: topicList_rect.top
                    anchors.topMargin: 10;anchors.leftMargin: 5
                    text: topicTitle
                    wrapMode: Text.WordWrap
                    font { bold: true; family: "Helvetica"; pointSize: 16}
                    horizontalAlignment: Text.AlignLeft
                }

                Text {
                    id:topic_time
                    width:topicList_rect.width; height: 20
                    anchors.left: topicList_rect.left;
                    anchors.top:topicTitle_text.bottom

                    anchors.bottomMargin: 10;anchors.leftMargin: 5

                    text: lastPostTime +"          回"+replayCount+"/点"+viewCount
                    wrapMode: Text.WordWrap
                    font { bold: false; family: "Helvetica"; pointSize: 14 }
                     horizontalAlignment: Text.AlignLeft
                }

          }
    }

     MouseArea {
            anchors.fill: parent
            onClicked: {
                console.log("get topicId:"+topicId);//传递参数：topicId 到具体文章页面，根据此参数获取文章页面

               ForumUtil.setCurrentTopicId(topicId);
                var pageNum="";
                var doc = new XMLHttpRequest();
                doc.onreadystatechange = function() {
                    if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
                    } else if (doc.readyState == XMLHttpRequest.DONE) {
                        var a = doc.responseXML.documentElement;

                        pageNum =a.childNodes[0].childNodes[1].childNodes[0].nodeValue;

                        ForumUtil.setCurrentTopicPageNum(pageNum);//传递帖子的总页数

                        CommonUtil.openFile("ForumClub.qml"); //具体帖子展示页面
                    }
                }

                doc.open("GET", ForumUtil.getClubReplyLink(topicId));
                doc.send();


            }

        }



 }
Rectangle{
    id:spanLine
    width:parent.width
    height: 3
    color:"white"
}

Rectangle{
      width:parent.width
      height:2
      anchors.top: listTiem_rect.bottom
      anchors.left: listTiem_rect.left
      anchors.topMargin: 1
 }

}
